# utils/config_loader.py
import os
import yaml


class ConfigLoader:
    """配置加载器：负责从 settings.yaml 中读取不同环境的配置"""
    SETTINGS_PATH = os.path.join(os.path.dirname(__file__), "../config/settings.yaml")

    @classmethod
    def load(cls, env: str = None) -> dict:
        """加载指定环境(ENV)的配置信息，默认为 staging"""
        if not env:
            env = os.getenv("ENV", "staging")
        with open(cls.SETTINGS_PATH, encoding="utf-8") as f:
            data = yaml.safe_load(f)
        return data.get("environments", {}).get(env, {})